<?php
if (!defined('CMS_SYSTEM')) die();
if ($disable_site) {
	echo "<center style=\"margin-top:200px;font-weight:bold\">".$disable_message ."</center>";
}else{
global $db,$Default_Temp, $time, $currentlang,$prefix;
if (file_exists(DATAFOLD."/config_introduce.php")) {
	include_once(DATAFOLD."/config_introduce.php");
}
include_once("templates/".$Default_Temp."/header.php");
  include_once("templates/".$Default_Temp."/banner.php");
  include_once("templates/".$Default_Temp."/menu.php");
  /*
   * Phan loc ra tat ca san pham
   * Le duc vien
   */
  /*
   * phan phan trang 
   * Le duc vien
   */
     $perpage = $prd_perpage_cathome;
     $page = intval(isset($_GET['page']) ? $_GET['page'] : (isset($_POST['page']) ? $_POST['page']:1));
	 $offset = ($page-1) * $perpage;
	 $countf = $db->sql_fetchrow($db->sql_query("SELECT COUNT(*) FROM {$prefix}_products WHERE active='1' AND alanguage='$currentlang'"));
	 $total = ($countf[0]) ? $countf[0] : 1;
	 $pageurl = "index.php?f=$module_name";
  /*
   * Ket thuc phan phan trag
   */
 echo "<div id=\"wrapper\">";
	 echo "<div class=\"content fix\">";
	     //Noi dung phan loc tat ca san pham
	     echo "<div class=\"w720 fl\">";
	       echo "<div class=\"common\">";
	            echo "<div class=\"title\">";
				 echo "<h1 class=\"text\"><a href=\"".url_sid("index.php?f=products")."\"><span>"._ALL_PRODUCT."</a></h1>";
			    echo "</div>";
			    echo "<div class=\"wrap fix\">";
			    $result_prds_index = $db->sql_query("SELECT id, title, description, images, pnews,price FROM ".$prefix."_products WHERE active='1' AND alanguage='$currentlang' ORDER BY time DESC LIMIT $offset,$perpage");
                if($db->sql_numrows($result_prds_index) > 0) {
                	while(list($id, $title, $description, $images, $pnews,$price) = $db->sql_fetchrow($result_prds_index)) 
                	{
                		$urlid = "$siteurl/".url_sid("index.php?f=$module_name&do=detail&id=$id");
	                	echo "<div class=\"product\">";
							
							if($images=="")
							{  
								echo "<a href=\"".$urlid."\" class=\"tooltip\" rel=\"<img src='images/nopic2.gif' width='$prd_sizedetail' height='210'/>\" >";
							        echo "<img src=\"images/nopic2.gif\" width='$prd_thumbsize' alt=\"\">";
							    echo "</a>";
							}else {	
								echo "<a href=\"".$urlid."\" class=\"tooltip\" rel=\"<img src='$path_upload/$module_name/$images' width='$prd_sizedetail' height='210'/>\" >";
								   echo "<img src=\"$path_upload/$module_name/$images\" width='$prd_thumbsize' alt=\"\">";
								echo "</a>";
							}
							
							echo "<p>"._PRICE_PRODUCT.": <strong class=\"f1\">".bsVndDot($price)." VNĐ</strong></p>";
							echo "<a href=\"".url_sid("index.php?f=products&do=cart&act=add&id=$id")."\" class=\"btnBuy\">"._CART_PRODUCT."</a>";
							echo "<a href=\"".url_sid("index.php?f=products&do=detail&id=$id")."\" title=\"$title\">$title</a>";
						echo "</div>";
                	}
                	echo "<div class=\"clear\"></div>";	
                	if($total > $perpage) {		
						echo "<div class=\"page fix\">";
						   echo "".paging_theme($total,$pageurl,$perpage,$page)."";
					echo "</div>";
                	}
                }
			    echo "</div>";
	       echo "</div>";
	     echo "</div>";
	     include_once("templates/".$Default_Temp."/rightbody.php");
	 echo "</div>";
	 themeSlideShow(8);
	 themeFooter();
 echo "</div>";
 /*
  * Ket thuc phan san pham
  * 
  */
     
include_once("templates/".$Default_Temp."/footer.php");
echo "<script type=\"text/javascript\">";
		echo "$(function() {";
			echo "$(\".tooltip\").tooltip({";
			echo "bodyHandler: function(){";
				echo "$(\"#tooltip\").css(\"width\", \"auto\");";
				echo "return this.rel;";
			echo "},";
			echo "track: true,";
			echo "showURL: false,";
			echo "extraClass: \"\"";
			echo "});";
		echo "});";
echo "</script>";
echo "<script type=\"text/javascript\" src=\"templates/".$Default_Temp."/js/tooltip.js\"></script><!--Dùng cho trang sản phẩm-->";	
}
?>